using System;
using System.Collections.Generic;
using System.Text;
using System.Reflection;

namespace MySHQ.DAL
{
    public class SessionManager
    {
        private static readonly NHibernate.ISessionFactory sessionFactory;
        static SessionManager()
        {
            sessionFactory = new NHibernate.Cfg.Configuration().Configure(Assembly.GetExecutingAssembly(), @"MySHQ.DAL.hibernate.cfg.xml").BuildSessionFactory();
        }

        public static NHibernate.ISession GetCurrentSession()
        {
            return sessionFactory.OpenSession();
        }

        public static void CloseSession()
        {
            if (sessionFactory != null)
            {
                sessionFactory.Close();
            }
        }
    }
}
